import java.io.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;

public class ParseByDom
{
    protected static final String _sourseFile = "source.xml";

    public static void main(String[] args)
    {
        try {
        File f = new File(ParseByDom._sourseFile);
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder(); 
        Document doc = builder.parse(f);
        System.out.println(doc.getXmlEncoding());
        System.out.println(doc.getDoctype().getName());
        } catch (Exception e){}
    }
}
